#!/bin/bash

currentdir=$(cd "$(dirname "$0")"; pwd)
echo "build directory: ${currentdir}."

echo -e "\nbuild pcre..."
autoreconf
./configure --enable-utf8 --enable-shared=no CFLAGS=-fPIC
make
make install DESTDIR=${currentdir}/build/linux

cp -rv "${currentdir}/build/linux/usr/local/lib/libpcre.a" ${currentdir}/../../../lib
cp -rv "${currentdir}/build/linux/usr/local/lib/libpcrecpp.a" ${currentdir}/../../../lib
cp -rv "${currentdir}/build/linux/usr/local/lib/libpcreposix.a" ${currentdir}/../../../lib

make clean
rm -rf ${currentdir}/build/linux/*

echo "====== pcre build success! ======"
